package com.gitee.wsl.compose.ui.slider

/*
 * Designed and developed by 2022 skydoves (Jaewoong Eum)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
import androidx.annotation.FloatRange
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.gestures.detectHorizontalDragGestures
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.State
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Canvas
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.ImageBitmapConfig
import androidx.compose.ui.graphics.LinearGradientShader
import androidx.compose.ui.graphics.Matrix
import androidx.compose.ui.graphics.Paint
import androidx.compose.ui.graphics.PaintingStyle
import androidx.compose.ui.graphics.TileMode
import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalDensity
//import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import com.gitee.wsl.common.ui.base.Point
import com.gitee.wsl.common.ui.ext.hexString
import com.gitee.wsl.common.ui.ext.toFloatArray
import com.gitee.wsl.compose.ui.base.Slider
import kotlinx.coroutines.flow.MutableStateFlow
import kotlin.math.abs
import kotlin.math.atan2
import kotlin.math.cos
import kotlin.math.max
import kotlin.math.sin
import kotlin.math.sqrt

*//**
 * BrightnessSlider allows you to adjust the brightness value of the selected color from color pickers.
 *
 * @param modifier [Modifier] to decorate the internal Canvas.
 * @param controller Allows you to control and interacts with color pickers and all relevant subcomponents.
 * @param borderRadius Radius of the border.
 * @param borderSize [Dp] size of the border.
 * @param borderColor [Color] of the border.
 * @param wheelImageBitmap [ImageBitmap] to draw the wheel.
 * @param wheelRadius Radius of the wheel.
 * @param wheelColor [Color] of th wheel.
 * @param wheelPaint [Paint] to draw the wheel.
 * @param initialColor [Color] of the initial state. This property works for [HsvColorPicker] and
 * it will be selected on rightmost of slider if you give null value.
 *//*
@Composable
fun Slider.Brightness(
    modifier: Modifier = Modifier,
    controller: ColorPickerController,
    borderRadius: Dp = 6.dp,
    borderSize: Dp = 5.dp,
    borderColor: Color = Color.LightGray,
    wheelImageBitmap: ImageBitmap? = null,
    wheelRadius: Dp = 12.dp,
    wheelColor: Color = Color.White,
    @FloatRange(from = 0.0, to = 1.0) wheelAlpha: Float = 1.0f,
    wheelPaint: Paint = Paint().apply {
        color = wheelColor
        alpha = wheelAlpha
    },
    initialColor: Color? = null,
) {
    var backgroundBitmap: ImageBitmap? = null
    var bitmapSize = IntSize(0, 0)
    val borderPaint: Paint = Paint().apply {
        style = PaintingStyle.Stroke
        strokeWidth = with(LocalDensity.current) { borderSize.toPx() }
        color = borderColor
    }
    val colorPaint: Paint = Paint().apply {
        color = controller.pureSelectedColor.value
    }
    var isInitialized by remember { mutableStateOf(false) }

    SideEffect {
        controller.isAttachedBrightnessSlider = true
    }

    Canvas(
        modifier = modifier
            .fillMaxWidth()
            .clip(RoundedCornerShape(borderRadius))
            .onSizeChanged { newSize ->
                val size =
                    newSize.takeIf { it.width != 0 && it.height != 0 } ?: return@onSizeChanged
                backgroundBitmap
                    ?.asAndroidBitmap()
                    ?.recycle()
                backgroundBitmap =
                    ImageBitmap(size.width, size.height, ImageBitmapConfig.Argb8888).apply {
                        val backgroundCanvas = Canvas(this)
                        backgroundCanvas.drawRoundRect(
                            left = 0f,
                            top = 0f,
                            right = size.width.toFloat(),
                            bottom = size.height.toFloat(),
                            radiusX = borderRadius.value,
                            radiusY = borderRadius.value,
                            paint = borderPaint,
                        )
                    }
                bitmapSize = size
            }
            .pointerInput(Unit) {
                detectTapGestures { offset ->
                    // calculate wheel position.
                    val wheelPoint = offset.x
                    val position: Float = if (wheelImageBitmap == null) {
                        val point = wheelPoint.coerceIn(
                            minimumValue = 0f,
                            maximumValue = bitmapSize.width.toFloat(),
                        )
                        point / bitmapSize.width
                    } else {
                        val point = wheelPoint.coerceIn(
                            minimumValue = 0f,
                            maximumValue = bitmapSize.width.toFloat(),
                        )
                        point / bitmapSize.width
                    }
                    controller.setBrightness(position.coerceIn(0f, 1f), fromUser = true)
                }
            }
            .pointerInput(Unit) {
                detectHorizontalDragGestures { change, _ ->
                    // calculate wheel position.
                    val wheelPoint = change.position.x
                    val position: Float = if (wheelImageBitmap == null) {
                        val point = wheelPoint.coerceIn(
                            minimumValue = 0f,
                            maximumValue = bitmapSize.width.toFloat(),
                        )
                        point / bitmapSize.width
                    } else {
                        val point = wheelPoint.coerceIn(
                            minimumValue = 0f,
                            maximumValue = bitmapSize.width.toFloat(),
                        )
                        point / bitmapSize.width
                    }
                    controller.setBrightness(position.coerceIn(0f, 1f), fromUser = true)
                }
            },
    ) {
        drawIntoCanvas { canvas ->
            backgroundBitmap?.let {
                // draw background bitmap.
                canvas.drawImage(it, Offset.Zero, Paint())

                // draw a linear gradient color shader.
                val startColor = Color.Black
                val endColor = controller.pureSelectedColor.value
                val shader = LinearGradientShader(
                    colors = listOf(startColor, endColor),
                    from = Offset.Zero,
                    to = Offset(bitmapSize.width.toFloat(), bitmapSize.height.toFloat()),
                    tileMode = TileMode.Clamp,
                )
                colorPaint.shader = shader
                canvas.drawRoundRect(
                    left = 0f,
                    top = 0f,
                    right = bitmapSize.width.toFloat(),
                    bottom = bitmapSize.height.toFloat(),
                    radiusX = borderRadius.value,
                    radiusY = borderRadius.value,
                    paint = colorPaint,
                )

                // draw wheel bitmap on the canvas.
                if (wheelImageBitmap == null) {
                    val position = controller.brightness.value
                    val point = (bitmapSize.width * position).coerceIn(
                        minimumValue = 0f,
                        maximumValue = bitmapSize.width.toFloat(),
                    )
                    canvas.drawCircle(
                        Offset(x = point, y = bitmapSize.height / 2f),
                        wheelRadius.toPx(),
                        wheelPaint,
                    )
                } else {
                    val position = controller.brightness.value
                    val point = (bitmapSize.width * position).coerceIn(
                        minimumValue = 0f,
                        maximumValue = bitmapSize.width.toFloat(),
                    )
                    canvas.drawImage(
                        wheelImageBitmap,
                        Offset(
                            x = point - (wheelImageBitmap.width / 2),
                            y = bitmapSize.height / 2f - wheelImageBitmap.height / 2,
                        ),
                        Paint(),
                    )
                }
                if (initialColor != null && !isInitialized) {
                    isInitialized = true
                    val brightness =
                        max(max(initialColor.red, initialColor.green), initialColor.blue)
                    controller.setBrightness(brightness, fromUser = false)
                }
            }
        }
    }
}


*//** Creates and remembers a [ColorPickerController] on the current composer. *//*
@Composable
fun rememberColorPickerController(): ColorPickerController {
    return remember { ColorPickerController() }
}

*//**
 * [ColorPickerController] allows you to control and interacts with the [ImageColorPicker], [HsvColorPicker],
 * and all relevant subcomponents. You can create and remember [ColorPickerController]
 * with the [rememberColorPickerController] extension.
 *//*
@Stable
 class ColorPickerController {

    *//** An [ImageBitmap] to be drawn on the canvas as a palette. *//*
    internal var paletteBitmap: ImageBitmap? = null

    *//** An [ImageBitmap] to be drawn on the canvas as a wheel. *//*
    internal var wheelBitmap: ImageBitmap? = null

    private val _selectedPoint: MutableState<Point> = mutableStateOf(Point(0f, 0f))

    *//** State of [Point], which represents the currently selected coordinate. *//*
     val selectedPoint: State<Point> = _selectedPoint

    private val _selectedColor: MutableState<Color> = mutableStateOf(Color.Transparent)

    *//** State of [Color], which represents the currently selected color value with alpha and brightness. *//*
     val selectedColor: State<Color> = _selectedColor

    *//** State of [Color], which represents the currently selected color value without alpha and brightness. *//*
    internal var pureSelectedColor: MutableState<Color> = mutableStateOf(Color.Transparent)

    *//** Alpha value to be applied with the selected color. *//*
    internal var alpha: MutableState<Float> = mutableFloatStateOf(1.0f)

    *//** Brightness value to be applied with the selected color. *//*
    internal var brightness: MutableState<Float> = mutableFloatStateOf(1.0f)

    *//** Radius to draw default wheel. *//*
    internal var wheelRadius: Dp = 12.dp
        private set

    *//** Paint to draw default wheel. *//*
    internal var wheelPaint: Paint = Paint().apply { color = Color.White }
        private set

    *//** Enable or not color selection. *//*
    private val enabled: MutableState<Boolean> = mutableStateOf(true)

    *//** Decide the content scale of the palette when draws. *//*
    private var paletteContentScale: PaletteContentScale = PaletteContentScale.FIT

    *//** Size of the measured canvas dimensions (width and height). *//*
    internal val canvasSize: MutableState<IntSize> = mutableStateOf(IntSize(0, 0))

    *//** Matrix of the [paletteBitmap], which is used to calculate pixel positions. *//*
    internal val imageBitmapMatrix: MutableState<Matrix> = mutableStateOf(Matrix())

    *//** Indicates if the color picker is HSV model. *//*
    internal var isHsvColorPalette: Boolean = false

    *//** Indicates if the alpha slider has been attached. *//*
    internal var isAttachedAlphaSlider: Boolean = false

    *//** Indicates if the brightness slider has been attached. *//*
    internal var isAttachedBrightnessSlider: Boolean = false

    internal var reviseTick = mutableIntStateOf(0)

    internal var colorChangedTick = MutableStateFlow<ColorEnvelope?>(null)

    //private val debounceHandler = Handler(Looper.getMainLooper())

    private var debounceDuration: Long = 0L

    *//** Set an [ImageBitmap] to draw on the canvas as a palette. *//*
    *//* fun setPaletteImageBitmap(imageBitmap: ImageBitmap) {
        val targetSize = canvasSize.value.takeIf { it.width != 0 && it.height != 0 }
            ?: throw IllegalAccessException(
                "Can't set an ImageBitmap before initializing the canvas",
            )
        val copiedBitmap = imageBitmap.asAndroidBitmap().copy(Bitmap.Config.ARGB_8888, false)
        val resized = when (paletteContentScale) {
            PaletteContentScale.FIT -> BitmapCalculator.scaleBitmap(copiedBitmap, targetSize)
            PaletteContentScale.CROP -> BitmapCalculator.cropBitmap(copiedBitmap, targetSize)
        }
        paletteBitmap = resized.asImageBitmap()
        copiedBitmap.recycle()
        selectCenter(fromUser = false)
        reviseTick.intValue++
    }*//*

    *//** Set a [PaletteContentScale] to the palette bitmap. *//*
    *//* fun setPaletteContentScale(paletteContentScale: PaletteContentScale) {
        this.paletteContentScale = paletteContentScale
    }*//*

    *//** Set an [ImageBitmap] to draw on the canvas as a wheel. *//*
     fun setWheelImageBitmap(imageBitmap: ImageBitmap?) {
        wheelBitmap = imageBitmap
    }

    *//** Set a radius to draw default wheel. *//*
     fun setWheelRadius(radius: Dp) {
        wheelRadius = radius
        reviseTick.intValue++
    }

    *//** Set a paint to draw default wheel. *//*
     fun setWheelPaint(paint: Paint) {
        wheelPaint = paint
        reviseTick.intValue++
    }

    *//** Set a color for the wheel. *//*
     fun setWheelColor(color: Color) {
        wheelPaint.color = color
        reviseTick.intValue++
    }

    *//** Set an alpha for the wheel. *//*
     fun setWheelAlpha(alpha: Float) {
        wheelPaint.alpha = alpha
        reviseTick.intValue++
    }

    *//** Enable or unable color selection. *//*
     fun setEnabled(enabled: Boolean) {
        this.enabled.value = enabled
    }

    *//** Set the debounce duration. *//*
     fun setDebounceDuration(duration: Long) {
        debounceDuration = duration
    }

    *//**
     * Select a specific point by coordinates and update a selected color.
     *
     * @param x x-coordinate to extract a pixel color.
     * @param y y-coordinate to extract a pixel color.
     * @param fromUser Represents this event is triggered by user or not.
     *//*
     fun selectByCoordinate(x: Float, y: Float, fromUser: Boolean) {
        enabled.value.takeIf { it } ?: return
        val snapPoint = PointMapper.getColorPoint(this, Point(x, y))
        val extractedColor = if (isHsvColorPalette) {
            extractPixelHsvColor(snapPoint.x, snapPoint.y)
        } else {
            extractPixelColor(snapPoint.x, snapPoint.y)
        }
        if (extractedColor != Color.Transparent) {
            // set the extracted color.
            pureSelectedColor.value = extractedColor
            _selectedPoint.value = Point(snapPoint.x, snapPoint.y)
            _selectedColor.value = applyHSVFactors(extractedColor)

            // notify color changes to the listeners.
            if (fromUser && debounceDuration != 0L) {
                notifyColorChangedWithDebounce(fromUser)
            } else {
                notifyColorChanged(fromUser)
            }
        }
    }

    *//**
     * Select a specific color and update with the selected color.
     *
     * @param color Color to be selected.
     * @param fromUser Represents this event is triggered by user or not.
     *//*
     fun selectByColor(color: Color, fromUser: Boolean) {
        val palette = paletteBitmap
        if (palette != null) {
            val pickerRadius: Float = palette.width.coerceAtMost(palette.height) * 0.5f
            if (pickerRadius > 0) {
                val hsv = FloatArray(3)
                android.graphics.Color.RGBToHSV(
                    (color.red * 255).toInt(),
                    (color.green * 255).toInt(),
                    (color.blue * 255).toInt(),
                    hsv,
                )
                val angle = (Math.PI / 180f) * hsv[0] * (-1)
                val saturationVector = pickerRadius * hsv[1]
                val x = saturationVector * cos(angle) + (palette.width / 2)
                val y = saturationVector * sin(angle) + (palette.height / 2)
                selectByCoordinate(x.toFloat(), y.toFloat(), fromUser)

                val brightness = max(max(color.red, color.green), color.blue)
                setBrightness(brightness, fromUser = false)
            }
        }
    }

    *//**
     * Select center point of the palette.
     *
     * @param fromUser Represents this event is triggered by user or not.
     *//*
     fun selectCenter(fromUser: Boolean) {
        val size = canvasSize.value
        selectByCoordinate(size.width * 0.5f, size.height * 0.5f, fromUser)
    }

    *//** Notify color changes to the color picker and other subcomponents. *//*
    private fun notifyColorChanged(fromUser: Boolean) {
        val color = _selectedColor.value
        colorChangedTick.value = ColorEnvelope(color, color.hexString, fromUser)
    }

    *//** Notify color changes to the color picker and other subcomponents with debounce duration. *//*
    private fun notifyColorChangedWithDebounce(fromUser: Boolean) {
        val runnable = { notifyColorChanged(fromUser) }
        //debounceHandler.removeCallbacksAndMessages(null)
        //debounceHandler.postDelayed(runnable, debounceDuration)
    }

    *//** Combine the alpha value to the selected pure color. *//*
    internal fun setAlpha(alpha: Float, fromUser: Boolean) {
        this.alpha.value = alpha
        _selectedColor.value = selectedColor.value.copy(alpha = alpha)
        notifyColorChanged(fromUser)
    }

    *//** Combine the brightness value to the selected pure color. *//*
     fun setBrightness(brightness: Float, fromUser: Boolean) {
        this.brightness.value = brightness
        val hsv = FloatArray(3)
        android.graphics.Color.colorToHSV(pureSelectedColor.value.toArgb(), hsv)
        hsv[2] = brightness
        _selectedColor.value = Color(android.graphics.Color.HSVToColor((alpha.value * 255).toInt(), hsv))
        if (fromUser && debounceDuration != 0L) {
            notifyColorChangedWithDebounce(fromUser)
        } else {
            notifyColorChanged(fromUser)
        }
    }

    *//** Return a [Color] that is applied with HSV color factors to the [color]. *//*
    private fun applyHSVFactors(color: Color): Color {
        val hsv = FloatArray(3)
        android.graphics.Color.colorToHSV(color.toArgb(), hsv)
        if (isAttachedBrightnessSlider) {
            hsv[2] = brightness.value
        }
        return if (isAttachedAlphaSlider) {
            Color(android.graphics.Color.HSVToColor((alpha.value * 255).toInt(), hsv))
        } else {
            Color(android.graphics.Color.HSVToColor(hsv))
        }
    }

    *//**
     * Extract a pixel color from the [paletteBitmap].
     *
     * @param x x-coordinate to extract a pixel color.
     * @param y y-coordinate to extract a pixel color.
     *
     * @return An extracted [Color] from the desired coordinates.
     * if fail to extract a pixel value, it will returns [Color.Transparent].
     *//*
    internal fun extractPixelColor(x: Float, y: Float): Color {
        *//*val invertMatrix = Matrix()
        imageBitmapMatrix.value.invert(invertMatrix)

        val mappedPoints = floatArrayOf(x, y)
        invertMatrix.mapPoints(mappedPoints)*//*

        val invertMatrix = imageBitmapMatrix.value
        invertMatrix.invert()
        val mappedPoints = invertMatrix.map(Point(x,y)).toFloatArray()


        val palette = paletteBitmap
        if (palette != null &&
            mappedPoints[0] >= 0 &&
            mappedPoints[1] >= 0 &&
            mappedPoints[0] < palette.width &&
            mappedPoints[1] < palette.height
        ) {
            val scaleX = mappedPoints[0] / palette.width
            val x1 = scaleX * palette.width
            val scaleY = mappedPoints[1] / palette.height
            val y1 = scaleY * palette.height
            val pixelColor = palette.asAndroidBitmap().getPixel(x1.toInt(), y1.toInt())
            return Color(pixelColor)
        }
        return Color.Transparent
    }

    private fun extractPixelHsvColor(x: Float, y: Float): Color {
        *//*val invertMatrix = Matrix()
        imageBitmapMatrix.value.invert(invertMatrix)

        val mappedPoints = floatArrayOf(x, y)
        invertMatrix.mapPoints(mappedPoints)*//*

        val invertMatrix = imageBitmapMatrix.value
        invertMatrix.invert()
        val mappedPoints = invertMatrix.map(Point(x,y)).toFloatArray()

        val palette = paletteBitmap
        if (palette != null &&
            mappedPoints[0] >= 0 &&
            mappedPoints[1] >= 0 &&
            mappedPoints[0] < palette.width &&
            mappedPoints[1] < palette.height
        ) {
            val x2 = x - palette.width * 0.5f
            val y2 = y - palette.height * 0.5f
            val size = canvasSize.value
            val r = sqrt((x2 * x2 + y2 * y2).toDouble())
            val radius: Float = size.width.coerceAtMost(size.height) * 0.5f
            val hsv = floatArrayOf(0f, 0f, 1f)
            (
                    (
                            atan2(
                                y2.toDouble(),
                                -x2.toDouble(),
                            ) / Math.PI * 180f
                            ).toFloat() + 180
                    ).also { hsv[0] = it }
            hsv[1] = 0f.coerceAtLeast(1f.coerceAtMost((r / radius).toFloat()))
            return Color(android.graphics.Color.HSVToColor(hsv))
        }
        return Color.Transparent
    }

    internal fun releaseBitmap() {
        paletteBitmap?.asAndroidBitmap()?.recycle()
        wheelBitmap?.asAndroidBitmap()?.recycle()
        paletteBitmap = null
        wheelBitmap = null
    }
}

*//**
 * Data transfer object that includes updated color factors.
 *
 * @param color ARGB color value.
 * @param hexCode Color hex code, which represents [color] value.
 * @param fromUser Represents this event is triggered by user or not.
 *//*
@Immutable
 data class ColorEnvelope(
    val color: Color,
    val hexCode: String,
    val fromUser: Boolean,
)


*//** Represents a rule to apply to scale a source rectangle to be inscribed into a destination. *//*
 enum class PaletteContentScale {
    *//**
     * Scale the source with maintaining the source's aspect ratio
     * so that both dimensions (width and height) of the source will be equal to or less than the
     * corresponding dimension of the target size.
     *//*
    FIT,

    *//**
     * Crop ths source the corresponding dimension of the target size.
     * so that if the dimensions (width and height) source is bigger than the target size,
     * it will be cut off from the center.
     *//*
    CROP,

    *//**
     * Scale the source with maintaining the source's aspect ratio
     * so that if both dimensions (width and height) of the source is smaller than the target size,
     * it will not be scaled.
     *//*
//    INSIDE,
}


*//**
 * PointMapper calculates correct coordinates corresponding to bitmap ratio and size.
 *//*
internal object PointMapper {

    internal fun getColorPoint(controller: ColorPickerController, point: Point): Point {
        val size = controller.canvasSize.value
        val center = Point(size.width / 2f, size.height / 2f)
        return if (controller.isHsvColorPalette) {
            getHuePoint(controller, point)
        } else {
            approximatedPoint(controller, point, center)
        }
    }

    private fun approximatedPoint(
        controller: ColorPickerController,
        start: Point,
        end: Point,
    ): Point {
        if (getDistance(start, end) <= 3) return end
        val center: Point = getCenterPoint(start, end)
        val color: Color = controller.extractPixelColor(center.x, center.y)
        return if (color == Color.Transparent) {
            approximatedPoint(controller, center, end)
        } else {
            approximatedPoint(controller, start, center)
        }
    }

    private fun getHuePoint(controller: ColorPickerController, point: Point): Point {
        val size = controller.canvasSize.value
        val centerX: Float = size.width * 0.5f
        val centerY: Float = size.height * 0.5f
        var x = point.x - centerX
        var y = point.y - centerY
        val radius = centerX.coerceAtMost(centerY)
        val r = sqrt((x * x + y * y).toDouble())
        if (r > radius) {
            x *= (radius / r).toFloat()
            y *= (radius / r).toFloat()
        }
        return Point(x + centerX, y + centerY)
    }

    private fun getCenterPoint(start: Point, end: Point): Point {
        return Point((end.x + start.x) / 2, (end.y + start.y) / 2)
    }

    private fun getDistance(start: Point, end: Point): Int {
        return sqrt(
            (
                    abs(end.x - start.x) * abs(end.x - start.x) +
                            abs(end.y - start.y) * abs(end.y - start.y)
                    ).toDouble(),
        ).toInt()
    }
}*/

/*
@Preview
@Composable
private fun PreviewSliderWithLabel() {
    MaterialTheme {
        Surface {
            val ctroll = rememberColorPickerController()
            var value by remember {
                mutableStateOf(1f)
            }
            Slider.Brightness(
                controller = ctroll,
            )
        }
    }
}*/
